package com.ruoyi.system.controller.system;

import cn.dev33.satoken.annotation.SaIgnore;
import com.ruoyi.common.core.annotation.Anonymous;
import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.system.service.UploadService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Tag(name = "后台:上传文件")
@RequestMapping("/upload")
public class UploadController {

    @Autowired
    private UploadService uploadService;
    /**
      上传到本地路径<br>
      弃用，请使用ruoyi自带的通用工具
     */
    @Deprecated
    @PostMapping("/uploadlocal")
    @Operation(summary = "上传文件到服务器本地" )
    public R<String> upload(@RequestParam("file") MultipartFile file) throws IOException {
        return R.ok(uploadService.uploadToLocal(file), "上传成功");
    }
}
